In [144]:
import numpy
from IPython import parallel
c = parallel.Client()
d0 = c[0]
d1 = c[1]
d = c[:]
for disp in (d0, d1, d):
disp.block = True
In [56]:
@d.parallel(block = True)
def f (l):
return len(l)
f(range(100))
Out[56]:
In [150]:
with d.sync_imports():
from math import sin
from math import pi
x = numpy.arange(0, 5 * pi, .01)
y = d.map(sin, x)
plot(x, y)
@d.parallel(block = True)
def work (l):
return [sin(x) for x in l]
y = work(x)
plot(x + pi / 2, y)
d.scatter('x', x)
%px y = [sin(a) for a in x]
y = d.gather('y')
plot(x + pi, y)
Out[150]: